Ext.namespace("Ext.ux.org.omorg");
Ext.ux.org.omorg.UserDetailPanel = Ext.extend(Ext.Panel, {
	//title : "用户详细信息",
	layout : "border",
	userId : null,
	posId : null,
	orgId : null,
	parentWinId : null,
	formPanel : null,
	initComponent : function() {
		Ext.ux.org.omorg.UserDetailPanel.superclass.initComponent.call(this);
		var b = new Ext.data.JsonReader({
					root : "result",
					id : "userId"
				}, [{
							name : "userId",
							mapping : "userId"
						}, {
							name : "loginName",
							mapping : "loginName"
						}, {
							name : "password",
							mapping : "password"
						}, {
							name : "userCode",
							mapping : "userCode"
						}, {
							name : "userName",
							mapping : "userName"
						}, {
							name : "certMode",
							mapping : "certMode"
						}, {
							name : "cssStyle",
							mapping : "cssStyle"
						}, {
							name : "sortNo",
							mapping : "sortNo"
						}, {
							name : "isActive",
							mapping : "isActive"
						}, {
							name : "position",
							mapping : "position"
						}, {
							name : "sex",
							mapping : "sex"
						}, {
							name : "title",
							mapping : "title"
						}, {
							name : "officeTel",
							mapping : "officeTel"
						}, {
							name : "mobile",
							mapping : "mobile"
						}, {
							name : "msn",
							mapping : "msn"
						}, {
							name : "email",
							mapping : "email"
						}, {
							name : "qq",
							mapping : "qq"
						}, {
							name : "rtx",
							mapping : "rtx"
						}, {
							name : "seatNo",
							mapping : "seatNo"
						}, {
							name : "startDate",
							mapping : "startDate"
						}, {
							name : "endDate",
							mapping : "endDate"
						}, {
							name : "creator",
							mapping : "creator"
						}, {
							name : "createTime",
							mapping : "createTime"
						}, {
							name : "updator",
							mapping : "updator"
						}, {
							name : "updateTime",
							mapping : "updateTime"
						}, {
							name : "remark",
							mapping : "remark"
						}]);
		var a = new Ext.FormPanel({
			region : "center",
			labelWidth : 85,
			labelAlign : "right",
			reader : b,
			frame : true,
			items : [{
				xtype : "fieldset",
				title : '<span class="fs_tip">请输入用户基本信息，标志 <span class="fs_flag">*</span> 字段为必填项</span>',
				layout : "form",
				items : [{
					layout : "column",
					items : [ {
						columnWidth : 1,
						layout : "form",
						items : [{
							fieldLabel : '<span class="fs_flag">*</span>&nbsp;用户姓名',
							xtype : "textfield",
							name : "userName",
							allowBlank : false,
							maxLength : 25,
							anchor : "98%"
						}]
					}]
				}, {
					layout : "column",
					items : [{
						columnWidth : 0.5,
						layout : "form",
						items : [{
							fieldLabel : "称谓",
							xtype : "textfield",
							name : "title",
							anchor : "96%"
						}]
					}, {
						columnWidth : 0.5,
						layout : "form",
						items : [{
							xtype : "twoItemCombo",
							itemType : "sex",
							fieldLabel : "性别",
							hiddenName : "sex",
							anchor : "96%"
						}]
					}]
				}, {
					layout : "column",
					items : [{
						columnWidth : 0.5,
						layout : "form",
						items : [{
							fieldLabel : "办公电话",
							xtype : "textfield",
							name : "officeTel",
							anchor : "96%"
						}]
					}, {
						columnWidth : 0.5,
						layout : "form",
						items : [{
							fieldLabel : "手机号码",
							xtype : "textfield",
							name : "mobile",
							anchor : "96%"
						}]
					}]
				}, {
					layout : "column",
					items : [{
						columnWidth : 0.5,
						layout : "form",
						items : [{
							fieldLabel : "MSN号",
							xtype : "textfield",
							name : "msn",
							anchor : "96%"
						}]
					},{
						columnWidth : 0.5,
						layout : "form",
						items : [{
							fieldLabel : "QQ号",
							xtype : "textfield",
							name : "qq",
							anchor : "96%"
						}]
					}]
				}, {
					layout : "form",
					fieldLabel : "电子邮箱",
					xtype : "textfield",
					name : "email",
					anchor : "98%"
				}, {
					layout : "form",
					xtype : "textarea",
					name : "remark",
					anchor : "98%",
					fieldLabel : "备注",
					hidden:true,
					hight : 40
				}, {
					xtype : "hidden",
					fieldLabel : "主键ID",
					name : "userId"
				}, {
					xtype : "hidden",
					fieldLabel : "失效日期",
					name : "endDate"
				}, {
					xtype : "hidden",
					fieldLabel : "生效日期",
					name : "startDate"
				}, {
					fieldLabel : "创建人",
					xtype : "hidden",
					name : "creator"
				}, {
					xtype : "hidden",
					fieldLabel : "创建时间",
					name : "createTime"
				}, {
					fieldLabel : "修改人",
					xtype : "hidden",
					name : "updator"
				}, {
					xtype : "hidden",
					fieldLabel : "修改时间",
					name : "updateTime"
				}, {
					xtype : "hidden",
					fieldLabel : "用户编号",
					name : "userCode"
				}, {
					xtype : "hidden",
					fieldLabel : "登录密码",
					name : "password"
				}, {
					xtype : "hidden",
					fieldLabel : "登录名称",
					name : "loginName"
				}, {
					xtype : "hidden",
					fieldLabel : "是否启用",
					name : "isActive"
				}, {
					xtype : "hidden",
					fieldLabel : "排列顺序",
					name : "sortNo"
				}, {
					xtype : "hidden",
					fieldLabel : "认证模式",
					name : "certMode"
				}, {
					xtype : "hidden",
					fieldLabel : "界面风格",
					name : "cssStyle"
				}, {
					xtype : "hidden",
					fieldLabel : "在岗情况",
					name : "position"
				}]
			}],
			buttons : [{
						text : "&nbsp;&nbsp;保存",
						width : 90,
						iconCls : "icon-middle-save",
						scale : "medium",
						handler : this.saveUser,
						scope : this
					}]
		});
		if (this.parentWinId != null) {
			a.addButton({
						text : "关闭窗口",
						width : 90,
						iconCls : "icon-middle-cancel",
						scale : "medium",
						handler : function(c, d) {
							this.closeParentWin()
						},
						scope : this
					})
		}
		this.add(a);
		this.formPanel = a
	},
	loadUser : function() {
		this.formPanel.load({
					url : ctx+"/ps-index!findUser.action",
					waitMsg : "正在载入数据...",
					failure : function() {
						Ext.Msg.alert("系统提示", "无法加载指定用户信息！")
					}
				})
	},
	closeParentWin : function() {
		var a = Ext.getCmp(this.parentWinId);
		if (a != null) {
			a.close()
		}
	},
	saveUser : function() {
		if (this.formPanel.form.isValid()) {
			this.formPanel.form.submit({
						url :ctx+"/ps-index!save.action",
						success : function(b, a) {
							this.closeParentWin()
						},
						failure : function(a, b) {
							Ext.Msg.alert("系统提示", "更新用户信息失败！")
						},
						waitMsg : "正在保存数据，请稍候...",
						scope : this
					})
		}
	}
});